//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#include "particleshooter.h"
#include "controller.h"
#include "particlesystem.h"
#include <model/particleshooter.h>
//
namespace player
{
ParticleShooter::ParticleShooter()
:
   Shooter(),
   shooter(0)
{
}
ParticleShooter::~ParticleShooter()
{
}
void ParticleShooter::init_setup(Controller *p_controller,const model::Shooter *p_shooter)
{
   Shooter::init_setup(p_controller,p_shooter);
   shooter=qobject_cast<const model::ParticleShooter*>(p_shooter);
   Q_ASSERT(shooter);
   particle_system=controller->particle_system_for_template(shooter->get_particle_template());
}
//
bool ParticleShooter::update(double /*dt*/)
{
   if(particle_system)
   {
      ParticleParam p;
      p.time=shooter->get_time();
      p.position=shooter->get_position();
      p.angle=shooter->get_angle();
      p.velocity=shooter->get_velocity();
      p.angular_velocity=shooter->get_angular_velocity();
      particle_system->schedule_create(p);
   }
   return false;
}
//
const model::Shooter *ParticleShooter::get_shooter()const
{
   return shooter;
}
}
